NET-RELOAD Utility for Visual Studio - Download Here - Autodesk Community - AutoCAD
Comunicados
System Maintenance: This site (The Autodesk Forums) will be down starting on September 1st from 11:59PM – 01:00AM PDT. We apologize for the inconvenience
cancelar
Mostrando resultados para 
Pesquisar então 
Você quer dizer: 
Esta página foi traduzida para sua maior comodidade, com o uso de um serviço de tradução automática. Esta não é uma tradução oficial e pode conter erros e imprecisões. A Autodesk não garante, expressa ou implicitamente, a precisão, a confiabilidade ou a integridade das informações traduzidas pelo serviço de tradução automática, e não se responsabiliza por eventuais perdas ou danos causados pela confiança depositada no serviço de tradução. Traduzir

NET-RELOAD Utility for Visual Studio - Download Here

39 RESPOSTAS 39
Responder
Highlighted
Mensagem 1 de 40
6703 Exibições, 39 Respostas

NET-RELOAD Utility for Visual Studio - Download Here

NET-RELOAD Utility

 

I’m sure many of you are aware that there is no "NETUNLOAD" command for unloading a .NET assembly from AutoCAD. Apparently this would require a significant change to AutoCAD's .NET API and is not likely to change anytime soon. Refer here for further details: http://through-the-interface.typepad.com/through_the_interface/2008/09/tired-of-not-be.html

 

As an alternative, I have created an AutoCAD utility that allows you to "re-load" an assembly after making modifications to your code - the best bit being you can do this WITHOUT having to re-start AutoCAD each time.

 

I’d be really interested in hearing if you find this utility useful for AutoCAD .NET development purposes.

 

Cheers,

Art

 

 

Instructions

 

To run the utility:

 

1. download the attached NetReload.dll.

2. run AutoCAD, but do NOT start it from Visual Studio.

3. NETLOAD the NetReload.dll into AutoCAD.

4. open Visual Studio and make sure a file from the particular project you wish to re-load is active.

5. go back to AutoCAD and run the NRL command.

6. in the command-line, select the Visual Studio instance you wish to re-load into AutoCAD.

 

If you subsequently go back to Visual Studio and change your code, and then re-run the NRL command in AutoCAD again, the code changes will automatically be loaded into AutoCAD and ready to use.

 

Note that you won’t be able to debug your code in Visual Studio with this tool (i.e. place breakpoints and step through code). You’ll have to re-start AutoCAD from within Visual Studio to do this.

 

 

Notes

 

1. Supports multiple opened instances of Visual Studio.

2. Has been checked in AutoCAD 2011 and 2012 (should also work in AutoCAD 2010).

3. Has been checked with Visual Studio 2010 (should also work for previous versions).

4. The NRL command will default to the last chosen solution for the current AutoCAD session.

5. The NRL command will advise if:

    - no Visual Studio instances are currently open.

    - no solutions are open in any of the currently opened Visual Studio instances.

    - no document is active for the chosen solution.

 

 

How It Works

 

Technically the NRL command does not actually re-load the assembly for the chosen Visual Studio solution. Instead it does the following:

 

1. accesses the chosen Visual Studio instance using Automation (i.e. COM).

2. based on the active Document for the Visual Studio instance, gets the project to compile.

3. sets the project’s "AssemblyName" property to a random name.

4. compiles the project to an assembly in the following project folder: "\bin\Debug\ReNetload"

5. sets the project’s " AssemblyName" property back to its orignal name.

6. NETLOADs the assembly from "\bin\Debug\ReNetload" into AutoCAD.

 

The reason this works is because when you NETLOAD the randomly named assembly into AutoCAD, all of the previously defined commands of the same name are overriden by those defined in the last loaded assembly.

 

 

Tips

 

A quick way to get this assembly to automatically load when AutoCAD starts is to add the lisp code below to the acad2010.lsp / acad2011.lsp / acad2012.lsp file. Obviously you will need to change this depending on where you place NetReload.dll.

 

(setq S::STARTUP (append S::STARTUP (list (command "netload" "C:\\MyAutoCAD\\ NetReload.dll") (princ))))

 

 

Source Code

 

I have attached the C# source code file so you can build this yourself.

 

Note that you will need to add the following project references so that it compiles:

 

1. envdte.dll (Visual Studio Automation - i.e. COM).

2. System.Windows.Forms.dll (WaitCursor helper class).

3. acdbmgd.dll and acmgd.dll (AutoCAD).

Highlighted
Mensagem 2 de 40
em resposta a: Artvegas

Of course. Are you kidding? This is going to a great help for me. I cannot wait to try it out on Monday. I am just starting out to rewrite my acad VBA applications to .NET and I have come to the conclusion that I will need to develop as much of the applications as I can independent of AutoCAD before adding in the AutoCAD aspects that will require netloading to continue development. I have considered doing manually what NRL does but as a VS greenhorn I am already overwhelmed performing even the simplest task. I hope you will share this and future applications with us.

 

Thank you!

 

aks

Highlighted
Mensagem 3 de 40
em resposta a: Artvegas

I built the project with no errors reported but Microsoft stepped in at Netload time telling me I did not have permissions to do so. I am using VS 2010 express. I can build and netload vb creations. Can you help with this? Thanks. 

Highlighted
Mensagem 4 de 40
em resposta a: aksaks

Hi aks,

 

Thanks for highlighting your issue. Unfortunately it appears that Visual Studio Automation (i.e. COM) is not supported for express editions. I assume this is the problem you are experiencing.

 

I do have another technique for automating this process using the pre-build event command line setting in Visual Studio. I'll send you a private message on here in a short while.

 

Cheers,
Art

Highlighted
Mensagem 5 de 40

I would not recommend this method for debugging:
1. If the application is subscribed with the events of AutoCAD - will be conflict.
2. If your application uses shared resources (file, database) - will be conflict.
3. If the application uses the palette - will be conflict.
Only in the simplest cases, you can use this algorithm.
IMHO.


Alexander Rivilis / Александр Ривилис
Programmer & Teacher & Helper / Программист - Учитель - Помощник
Facebook | Twitter | LinkedIn

Highlighted
Mensagem 6 de 40
em resposta a: Artvegas

I cannot "build" my app after it has been netloaded in acad.  VS 2008 gives me this message:

 

Error 1 Unable to copy file "obj\Release\ViewPorts.dll" to "bin\Debug\ViewPorts.dll". The process cannot access the file 'bin\Debug\ViewPorts.dll' because it is being used by another process. ViewPorts

 

1. Start acad

2. Load app

3. Make changes to code

4. Build generates error

Highlighted
Mensagem 7 de 40

Hi Alexander,

 

Yes these should definately be kept in mind. This utility will not necessarily suit some of the situations you listed, and I wouldn't say it's the way to go when debugging large fully fledged applications.

 

But if you're just looking to experiment with different parts of the API it is very cumbersome to:

1. Close the drawing you are working on.

2. Close AutoCAD.

3. Change your code in Visual Studio.

4. Build your dll in Visual Studio.

5. Re-start AutoCAD.

6. Re-open the drawing you are working on.

7. NETLOAD your revised dll.

 

Especially for every change you make to your code - no matter how small. With my utility you can skip steps 1, 2, 4, 5, 6 and 7 above. All you have to do is change your code in Visual Studio and then run my NRL command in AutoCAD.

 

I like to think this is for the pragmatist. It's saved me loads of time.

 

Thank you for your feedback.

 

Art

Highlighted
Mensagem 8 de 40
em resposta a: fieldguy

Hi fieldguy,

 

Yes that is the error you will receive in Visual Studio when you try to build (F6) to a dll that has already been loaded into AutoCAD (i.e. using NETLOAD). Makes sense to me.

 

It's important to understand with this utility that you don't actually do anything from Visual Studio (other than change your code).

 

In order to use the utility, please try the following:

1. Download the attached zip file from my original post and extract the NetReload.dll file.

2. Open your solution in Visual Studio and make sure that at least one of your project's code files are current.

3. In AutoCAD, load the NetReload.dll (i.e. using NETLOAD).

4. Run the NRL command in AutoCAD. This command will do all of the work for you. You will be prompted from within AutoCAD to select a running instance of Visual Studio. The command will then automatically build the solution and load it into AutoCAD. You won't have to switch back to Visual Studio.

 

Please don't hesitate to let me know how this goes for you, or if you have any further questions on this.

 

Cheers,

Art

Highlighted
Mensagem 9 de 40
em resposta a: Artvegas

I understand now.  Thank you very much - this is an awesome tool!  Nice code - that opens some new doors.  Thanks for sharing.

 

The user has to make sure to build from VS at the end of the development process to make sure the dll with the desired name matches the "tempassemblyname" dll. 

Highlighted
Mensagem 10 de 40
em resposta a: fieldguy

Hi fieldguy,

 

Yes that's right. The utility creates randomly named dll files in the "bin\Debug\NetReload\" folder. Once you're finished you should build (F6) your solution in Visual Studio to update the dll in the "bin\Debug\" folder.

 

Glad you like it Smiley feliz

 

Art

Highlighted
Mensagem 11 de 40
em resposta a: Artvegas

My initial problem is caused by the assembly being loaded off our local network. I am able to netload it when it resides on my local drive. Now the problem is , "No running Viusla Studio instances were found." I am hoping this can be fixed with a tweak to the code somewhere. Do you think this is possible?

 

Thanks, aks

Highlighted
Mensagem 12 de 40

As an alternative - simply rename the dll-file and create a new one with the same name


Alexander Rivilis / Александр Ривилис
Programmer & Teacher & Helper / Программист - Учитель - Помощник
Facebook | Twitter | LinkedIn

Highlighted
Mensagem 13 de 40
em resposta a: aksaks

I think you need to search here for CASPOL.  You can run dlls locally or setup CASPOL to allow access to user defined network dlls.

Highlighted
Mensagem 14 de 40
em resposta a: aksaks

Hi aks,

 

Did you get my response to your last post?

 

I don't believe this will work for VS express editions. However I might have another way of doing this with express.

 

I sent you a private message. To access your messages just click on the mail symbol at the top of the webpage (as shown in the pic below):

 

undefined

 

Hope to hear back from you soon.

 

Art

Highlighted
Mensagem 15 de 40
em resposta a: Artvegas

Hi Alexander,

 

I did try that - unfortunately renaming dll files doesn't work. The commands don't get overriden.

 

It appears that the dll files need to have different Intermediate Language (IL) signatures. Then the commands are overriden in AutoCAD with subsequent NETLOADs.

 

If you change a project's AssemblyName property before you compile the dll files, then it works. I'm not exactly sure of the reason. I'm guessing when I say it might have something to do with the way AutoCAD loads .NET assemblies into its AppDomain.

 

Art

Highlighted
Mensagem 16 de 40
em resposta a: fieldguy

Thanks for reminding me about CASPOL. I did not have rights to do that the last time I looked into this. I'll give it another shot. Thanks 

Highlighted
Mensagem 17 de 40
em resposta a: Artvegas

I am a fairly seasoned .NET developer and have been battling to set up a reasonable environment in which to work with Autocad 2013 / Visual Studio 2012. It has been quite a pain between not being able to debug, nor being able to "netreload" an assembly. This little utility is clever as hell, useful as all getout, and the first bit of light in my otherwise dismal experience with this. Nice work-around. Thank you Artvegas! 

 

FYI I had to set up a project and recompile it to get NetReload.dll to work in Autocad 2013. Also, the EnvDTE assembly can be referenced from Assemblies --> Extensions. Had to search for that a bit.

 

Kevin

Inventor 2013
Highlighted
Mensagem 18 de 40
em resposta a: Artvegas

First... Thank you very much!!!!

 

For those using the new Microsoft Visual Studio 2012 Express for Windows Desktop edition, here's the compatible version I compiled.

 

NetReload2013 command to run!

Serafin A. Albiero Jr.
Highlighted
Mensagem 19 de 40
em resposta a: Artvegas

Hi ,

 

I have tried to load your dll file direct with netload command. It shows me below error:

 

Command: netload
Cannot load assembly. Error details: System.IO.FileLoadException: Could not
load file or assembly 'file:///C:\Users\alamzaki\Desktop\VB_PPT\NetReload.dll'
or one of its dependencies. Operation is not supported. (Exception from
HRESULT: 0x80131515)
File name: 'file:///C:\Users\alamzaki\Desktop\VB_PPT\NetReload.dll' --->
System.NotSupportedException: An attempt was made to load an assembly from a
network location which would have caused the assembly to be sandboxed in
previous versions of the .NET Framework. This release of the .NET Framework
does not enable CAS policy by default, so this load may be dangerous. If this
load is not intended to sandbox the assembly, please enable the
loadFromRemoteSources switch. See http://go.microsoft.com/fwlink/?LinkId=155569
for more information.
   at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String
codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint,
StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean
forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String
codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint,
StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean
forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName
assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean
forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.RuntimeAssembly.InternalLoadFrom(String assemblyFile,
Evidence securityEvidence, Byte[] hashValue, AssemblyHashAlgorithm
hashAlgorithm, Boolean forIntrospection, Boolean suppressSecurityChecks,
StackCrawlMark& stackMark)
   at System.Reflection.Assembly.LoadFrom(String assemblyFile)
   at Autodesk.AutoCAD.Runtime.ExtensionLoader.Load(String fileName)
   at loadmgd()

 

Can you have a look at this? It seems to me that this utility would be great if I can use it. I use only VB so I did not build your C# code into dll. Do you have VB command for this utility?

Highlighted
Mensagem 20 de 40
em resposta a: mzakiralam

Sorry , I forgot to add my ACAD version. I am using ACAD2011 to load your dll

Não encontrou o que está procurando? Pergunte à comunidade ou compartilhe seu conhecimento.

Postar nos fóruns  

”Services